Opensky

OpenSky provides api to get data for flights in progress. It is rate limited

Code
import requests
import pandas as pd
import geopandas
Code
def fetch_opensky_data():
    url = "https://opensky-network.org/api/states/all"
    response = requests.get(url)
    data = response.json()

    columns = [
        "icao24", "callsign", "origin_country", "time_position", "last_contact",
        "longitude", "latitude", "baro_altitude", "on_ground", "velocity",
        "heading", "vertical_rate", "sensors", "geo_altitude", "squawk",
        "spi", "position_source"
    ]

    df_raw = pd.DataFrame(data['states'], columns=columns)
    return (
        df_raw
        .assign(
            time_position=pd.to_datetime(df_raw["time_position"], unit="s"),
            last_contact=pd.to_datetime(df_raw["last_contact"], unit="s"),
        )
    )

df_flights = fetch_opensky_data()


df_flihts_non_nan = df_flights.dropna(subset=["longitude", "latitude"])
gdf = geopandas.GeoDataFrame(
    df_flihts_non_nan,
    geometry=geopandas.points_from_xy(df_flihts_non_nan.longitude, df_flihts_non_nan.latitude),
    crs="EPSG:4326",
)

gdf.explore(fullscreen=True, tooltip=False, popup=True)
Make this Notebook Trusted to load map: File -> Trust Notebook

Flights in world at notebook time

Number of flights by origin_country

Code
(
    df_flights
    .groupby("origin_country")
    .agg(num_flights=("icao24", "count"))
    .sort_values("num_flights", ascending=False)
    .head(20)
)
num_flights
origin_country
United States 6756
Canada 392
United Kingdom 368
Ireland 299
Germany 220
Turkey 187
France 182
Malta 173
Spain 164
Austria 146
Kingdom of the Netherlands 128
Brazil 118
India 112
United Arab Emirates 103
China 101
Mexico 97
Switzerland 87
Poland 79
Republic of Korea 57
Sweden 57

Top 20 countries with most flights

All flights

For reference

Code
df_flights
icao24 callsign origin_country time_position last_contact longitude latitude baro_altitude on_ground velocity heading vertical_rate sensors geo_altitude squawk spi position_source
0 a8a812 N657PT United States 2025-05-15 19:50:21 2025-05-15 19:50:21 -106.4123 45.8444 13106.40 False 241.80 269.51 0.33 None 13167.36 4077 False 0
1 a7250f N56FA United States 2025-05-15 19:49:01 2025-05-15 19:49:03 -118.4882 34.2084 213.36 False 8.76 356.63 0.00 None 198.12 None False 0
2 39de4b France NaT 2025-05-15 19:50:21 NaN NaN 10546.08 False 220.75 131.98 9.10 None 10706.10 0656 False 0
3 39de4a TVF18AN France 2025-05-15 19:50:21 2025-05-15 19:50:21 10.0075 47.7024 10355.58 False 242.35 262.44 -0.33 None 10401.30 1000 False 0
4 39de4d TVF54UR France 2025-05-15 19:50:21 2025-05-15 19:50:22 1.9363 48.5843 1165.86 False 94.89 60.79 0.00 None 1272.54 0745 False 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
10908 a6d83c DAL2921 United States 2025-05-15 19:50:21 2025-05-15 19:50:21 -112.0365 40.8568 2232.66 False 117.60 291.29 4.88 None 2255.52 6034 False 0
10909 a4cbd6 N408RF United States 2025-05-15 19:50:21 2025-05-15 19:50:21 -79.9957 33.1121 617.22 False 76.76 135.27 -1.63 None 609.60 None False 0
10910 a9bc8a N7262X United States 2025-05-15 19:48:55 2025-05-15 19:48:55 -84.3605 35.5589 457.20 False 35.29 306.70 -3.90 None 449.58 2260 False 0
10911 ad00be N937MA United States 2025-05-15 19:50:21 2025-05-15 19:50:21 -83.9749 39.6819 609.60 False 51.82 60.89 -1.63 None 563.88 1200 False 0
10912 c00734 WJA1480 Canada 2025-05-15 19:50:21 2025-05-15 19:50:21 -104.0575 37.3548 11277.60 False 237.52 140.45 -0.65 None 11460.48 3376 False 0

10913 rows × 17 columns